﻿using ReportSystem_XY.Utility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;

namespace ReportSystem_XY.Models
{
    public class UserInfos
    {
        public int UserId { get; set; }
        public string UserName { get; set; }
        public string UserPwd { get; set; }

        public int RoleId { get; set; }
        public string RoleName { get; set; }

        public static List<UserInfos> GetUserInfoListAll(string sql)
        {
            List<UserInfos> userInfoBases = new List<UserInfos>();
            DataTable dt = SQLHelper.ExecuteDataTable(sql);
            foreach (DataRow dr in dt.Rows)
            {
                userInfoBases.Add(dr.DataRowToModel<UserInfos>());//反射
            }
            return userInfoBases;
        }

        public static bool Insert(string userName,string userPwd, int roleId)
        {
            string sql = "insert into userinfos (UserName,UserPwd,RoleId) Values('" + userName + "','" + userPwd + "'," + roleId + ")";
            int result = SQLHelper.ExecuteNonQuery(sql);
            return result > 0;

        }
    }
}
